import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:sph_shipper/Main/WaybillInvoicing/Invoicing.dart';

import '../../AppConfig/Config.dart';
import '../../http/NoLoadingGetApi.dart';
import '../../l10n/messages.dart';

class InvoicingHistory extends StatefulWidget {
  const InvoicingHistory({super.key});

  @override
  State<InvoicingHistory> createState() => _InvoicingHistoryState();
}

class _InvoicingHistoryState extends State<InvoicingHistory> {
  List typeList=["开票中","开票完成"];
  @override
  void initState() {
    // TODO: implement initState
    super.initState();

  }

  @override
  Widget build(BuildContext context) {
    var messages = AppLocalizations.of(context)!;
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
      appBar: AppBar(
        backgroundColor: Colors.white,
        centerTitle: true,
        title: Text(messages["运单开票"],style: TextStyle(color: Colors.black,fontWeight: FontWeight.w300,fontSize: 16.sp),),
      ),
      body: ListView(
        children: [
          Container(
            height: typeList.length*108.h,
            child:  ListView.builder(
                itemCount: typeList.length,
                itemBuilder: (BuildContext context, int index) {
                  return   Container(
                    margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),
                    padding: EdgeInsets.only(left: 8.w,right: 8.w,top: 10.h,bottom: 10.h),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(10),),
                    ),
                    child: Column(
                      children: [
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Row(
                              children: [
                                Text("苏州"+" "+"吴中",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w600),),
                                SizedBox(width: 8.w,),
                                Icon(Icons.trending_flat,),
                                SizedBox(width: 8.w,),
                                Text("宁波"+" "+"北仑",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w600),),
                              ],
                            ),
                            Text("2023-03-27 10:20",style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
                          ],
                        ),
                        SizedBox(height: 20.h,),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Row(
                              crossAxisAlignment: CrossAxisAlignment.end,
                              children: [
                                SizedBox(width: 40.w,),
                                Text("¥",style: TextStyle(color: MyColors.themeColor,),),
                                Text("300",style: TextStyle(color: MyColors.themeColor,fontSize: 20.sp),),
                              ],
                            ),
                            Text(typeList[index],style: TextStyle(color: MyColors.themeColor,),),
                          ],
                        ),
                      ],
                    ),
                  );
                }
            ),
          )

        ],
      ),
      floatingActionButton: SizedBox(

    width: 86.0, // 设置悬浮按钮的宽度
     child: GestureDetector(
       child:Container(
         width: 86.w,
         height: 30.h,
         decoration: BoxDecoration(
           color: MyColors.themeColor,
           borderRadius: BorderRadius.all(  Radius.circular(30),),
           gradient: LinearGradient(
             colors: [MyColors.themeColor, Color(0xFFEFA052)],
             begin: Alignment.topCenter,
             end: Alignment.bottomCenter,
           ),
         ),
         child: Center(
           child: Text("开票",style: TextStyle(color: Colors.white, ),),
         ),

       ),
       onTap: (){
         Navigator.push(context,
             MaterialPageRoute(builder: (context) {
               return Invoicing();
             }));
       },
     ),
      ),

      floatingActionButtonLocation: CustomFloatingActionButtonLocation(),
    );

  }

}
class CustomFloatingActionButtonLocation extends FloatingActionButtonLocation {
  @override
  Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) {
    // 自定义偏移位置
    double x = scaffoldGeometry.scaffoldSize.width -
       100; // 56.0 是 FloatingActionButton 默认宽度
    double y = scaffoldGeometry.scaffoldSize.height - 200.0; // 200.0 是距离底部的高度
    return Offset(x, y);
  }
}